package com.coocaa.app.lib.cleaner.deleter.pkgcache;

import android.content.Context;

import com.coocaa.app.lib.cleaner.deleter.AbstractDeleter;
import com.coocaa.app.lib.cleaner.deleter.pkgcache.impl.PackageCacheDeleterImpl;
import com.coocaa.app.lib.cleaner.mgr.DataHolder;

import java.util.List;

/**
 * Created by lu on 17-4-13.
 */

public abstract class PackageCacheDeleterFactory {
    /**
     * Created by lu on 17-4-13.
     */

    public interface PackageCacheDeleter extends AbstractDeleter {
        interface PackageCacheDeleterListener {

            void onPackageCacheDeleterAllStart();

            void onPackageCacheDeleterStart(String packageName);

            void onPackageCacheDeleterEnd(String packageName, boolean result, long size);

            void onPackageCacheDeleterAllEnd();
        }

        void delete(Context context, DataHolder.SinglePackageCache cache, PackageCacheDeleterListener listener);

        void delete(Context context, List<DataHolder.SinglePackageCache> caches, PackageCacheDeleterListener listener);
    }


    public static final PackageCacheDeleterFactory factory = new PackageCacheDeleterFactory() {
        private PackageCacheDeleter deleter = null;


        @Override
        public PackageCacheDeleter create() {
            return new PackageCacheDeleterImpl();
        }

        @Override
        public synchronized PackageCacheDeleter instance() {
            if (deleter == null)
                deleter = create();
            return deleter;
        }
    };

    public abstract PackageCacheDeleter create();

    public abstract PackageCacheDeleter instance();

}
